﻿#region 版本信息
/* ========================================================================
* 【本类功能概述】
* 
* 文件名：IMvcServiceExtensions
* 版本：4.0.30319.42000
* 作者：zl 时间：2016/2/23 17:53:48
* 邮箱：zaixy_8802@126.com
* ========================================================================
*/
#endregion


#region 主体

using System.IO;
using Abp.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace KelonProud
{
    using System.Text;
    using Abp.Application.Services;

    public static class MvcServiceExtensions
    {
        #region Json
        public static JsonResult Json(this IApplicationService service, object data)
        {
            return new JsonResult(data, new JsonSerializerSettings()
            {
                
            });
        }

        #endregion

        #region
        public static FileContentResult File(this IApplicationService service, byte[] fileContents, string contentType)
        {
            return File(service, fileContents, contentType,"");
        }

        public static FileContentResult File(this IApplicationService service, byte[] fileContents, string contentType, string fileDownloadName)
        {
            return new FileContentResult(fileContents, contentType){ FileDownloadName = fileDownloadName };
        }

        public static FileStreamResult File(this IApplicationService service, Stream fileStream, string contentType)
        {
            return File(service, fileStream, contentType, null);
        }

        public static FileStreamResult File(this IApplicationService service, Stream fileStream, string contentType, string fileDownloadName)
        {
            return new FileStreamResult(fileStream, contentType){FileDownloadName = fileDownloadName};
        }

        public static FileResult File(this IApplicationService service, string fileName, string contentType)
        {
            return File(service,fileName, contentType, null /* fileDownloadName */);
        }

        public static FileResult File(this IApplicationService service, string fileName, string contentType, string fileDownloadName)
        {
            return new PhysicalFileResult(fileName, contentType) { FileDownloadName = fileDownloadName };
        }
        #endregion
    }
}
#endregion
